import java.util.*;

class Solution {
    public int[] singleNumbers(int[] nums) {
        int sum = 0;
        for (int i = 0; i < nums.length; i++) {
            sum ^= nums[i];
        }
        int bits = 0;
        for (int i = 0; i <= Integer.SIZE; i++) {
            if ((sum & 1) == 1) {
                bits = i;
                break;
            }
            sum = sum >> 1;
        }
        int[] res = new int[]{0, 0};
        for (int i = 0; i < nums.length; i++) {
            if (((nums[i] >> bits) & 1) == 1) {
                res[0] ^= nums[i];
            } else {
                res[1] ^= nums[i];
            }
        }
        return res;
    }

    public static void main(String[] args) {
        int[] para = new int[]{2, 1, 5, 2};
        int[] res = new Solution().singleNumbers(para);
        System.out.println(Arrays.toString(res));
    }
}